﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DevComponents.DotNetBar.Controls;
using QuanLyDoanVien.DataLayer;
using QuanLyDoanVien.General;
using QuanLyDoanVien.Bussiness;
using System.Windows.Forms;

namespace QuanLyDoanVien.Controller
{
    class HocSinhCtrl
    {
        HocSinhData m_HocSinhData = new HocSinhData();
        HocSinhInfo m_HocSinhInfo = new HocSinhInfo();
        public bool capNhatNhanXet(string maHS, string nhanXet)
        {
            return m_HocSinhData.capNhatNhanXet(maHS, nhanXet);
        }
        public DataTable layRenLuyenHS(string maHocSinh)
        {
            return m_HocSinhData.layRenLuyenHS(maHocSinh);
        }
        public DataTable layRenLuyenHSTheoLop(string maLop)
        {
            return m_HocSinhData.layRenLuyenHSTheoLop(maLop);
        }
        public List<HocSinhInfo> layDSHS()
        {
            return m_HocSinhData.layDSHS();
        }
        public List<HocSinhInfo> layHocSinhTheoLop(string maLop)
        {
            return m_HocSinhData.layHocSinhTheoLop(maLop);
        }
        public DataTable layHocSinhTheoLop1(string maLop)
        {
            return m_HocSinhData.layHocSinhTheoLop1(maLop);
        }
        public String layTenHocSinh(String maHS)
        {
            return m_HocSinhData.layTenHocSinh(maHS);
        }
        public DataRow LayThongTin1HS(String maHS)
        {
            return m_HocSinhData.LayThongTin1HS(maHS);
        }
        public string getAutoID()
        {
            return m_HocSinhData.getAutoID();
        }
        public bool ChuyenHocSinh(String malopdi, String malopden)
        {
            return m_HocSinhData.ChuyenHocSinh(malopdi, malopden);
        }
        public bool DanhDau_RaTruong(String malop, int rt)
        {
            return m_HocSinhData.DanhDau_RaTruong(malop, rt);
        }
        #region Hien Thi Combobox
        public void HienThiComboBox(ComboBox cbx)
        {
            DataTable m_DT = m_HocSinhData.LayHocSinh();
            cbx.DataSource = m_DT;
            cbx.DisplayMember = "HoTen";
            cbx.ValueMember = "MaHocSinh";
        }
        #endregion

        #region Lay DS Hoc Sinh
        public static IList<HocSinhInfo> LayDsHocSinh()
        {
            IList<HocSinhInfo> ds = new List<HocSinhInfo>();

            HocSinhData data = new HocSinhData();
            DataTable tbl = data.LayDSHocSinh();

            IList<HocSinhInfo> HocSinh = new List<HocSinhInfo>();

            foreach (DataRow row in tbl.Rows)
            {
                HocSinhInfo HS = new HocSinhInfo();

                HS.MaHocSinh = Convert.ToString(row["MaHocSinh"]);
                HS.HoTen = Convert.ToString(row["HoTen"]);
                HS.MaLop = Convert.ToString(row["MaLop"]);
                HS.NgaySinh = Convert.ToString(row["NgaySinh"]);
                HS.NgayVaoDoan = Convert.ToString(row["NgayVaoDoan"]);
                HS.HoTenCha = Convert.ToString(row["HoTenCha"]);
                HS.HoTenMe = Convert.ToString(row["HoTenMe"]);
                HS.SoDTCha = Convert.ToString(row["SoDTCha"]);
                HS.SoDTMe = Convert.ToString(row["SoDTMe"]);
                HS.SoDTHS = Convert.ToString(row["SoDTHS"]);
                HS.TuoiCha = Convert.ToInt32(row["TuoiCha"]);
                HS.TuoiMe = Convert.ToInt32(row["TuoiMe"]);
                HS.NgheCha = Convert.ToString(row["NgheCha"]);
                HS.NgheMe = Convert.ToString(row["NgheMe"]);
                HS.Email = Convert.ToString(row["Email"]);
                HS.NoiSinh = Convert.ToString(row["NoiSinh"]);
                HS.GioiTinh = Convert.ToString(row["GioiTinh"]);
                HS.THCS = Convert.ToString(row["THCS"]);
                HS.MaChucVu = Convert.ToString(row["MaChucVu"]);




                HocSinh.Add(HS);
            }
            return HocSinh;
        }
        #endregion


        #region them hoc sinh
        public void ThemHocSinh(HocSinhInfo hs)
        {
             m_HocSinhData.ThemHocSinh(hs);
        }
        #endregion
        #region  sua hoc sinh
        public bool SuaHocSinh(HocSinhInfo hs)
        {
            return m_HocSinhData.SuaHocSinh(hs);
        }
        #endregion

        #region xoa hoc sinh
        public bool XoaHocSinh(String mHS)
        {
            return m_HocSinhData.XoaHocSinh(mHS);
        }
        #endregion

        public DataTable TimKiemTheoTen(string ten)
        {
            return m_HocSinhData.TimKiemTheoTen(ten);
        }
    }
}
